#find the median of the two sorted arrays in O(log(m+n))

#nums1 = [1,3], nums2 = [2]
#the median is 2.0

#num1 = [1,2], nums2 = [3,4]
#the median is 2.5

#要找到最中间的值，我们可以写一个函数找到第k个值

class Solution:
    def findKthSortedArray(self,A,B,k):
        if len(A) > len(B):
            A,B = B,A
        if not A:
            return B[k]
        if k == len(A) + len(B) - 1:
            return max(A[-1], B[-1])
        i = len(A) / 2
        j = k - i
        if A[i] > B[j]:
            return self.findKth(A[:i], B[j:], i)
        else:
            return self.findKth(A[i:], B[j:], j)



    def findMedianSortedArray(self, A, B):
        pass
